//
//  UIWindow+JTExtension.m
//  百思不得姐
//
//  Created by Robin Zhang on 2017/1/20.
//  Copyright © 2017年 BeiJingWangDianJieTong. All rights reserved.
//

#import "UIWindow+JTExtension.h"

@implementation UIWindow (JTExtension)

+ (instancetype)jt_highestVisibleWindow {
    
    UIApplication *application = [UIApplication sharedApplication];
    
    UIWindow *keyWindow = application.keyWindow;
    
    if (keyWindow.windowLevel != UIWindowLevelNormal) {
        
        for (NSInteger i = application.windows.count - 1; i >= 0; i--) {
            
            UIWindow *window = [application.windows objectAtIndex:i];
            if (window.windowLevel == UIWindowLevelNormal) {
                
                keyWindow = window;
                break;
            }
        }
    }
    
    return keyWindow;
}

@end
